<?php

class FileReader {
    
    function __construct() {
        
    }
    
    public function read($file) {
        if(!is_file($file)){
            throw new Exception(ERR_MSG_FILE_1, ERR_CODE_FILE_1);
        }
        
        if( filesize($file) > MAX_FILE_SIZE){
            throw new Exception(ERR_MSG_FILE_3, ERR_CODE_FILE_3);
        }
        
        $stream = file_get_contents($file);
        if($stream === false || empty($stream)){
            throw new Exception(ERR_MSG_FILE_2,ERR_CODE_FILE_2);
        }
        return $stream;
    }
}